import path from "path";
const absPath = (retivePath) => path.resolve(process.cwd(), retivePath)
import { defineConfig, loadEnv } from "vite";
import postcssPresetEnv from "postcss-preset-env";
const envMap = {
    "build": () => {
        console.log('生产环境');
        return {
        }
    },
    "serve": (mode) => {
        console.log('开发环境');
        return {
        }
    }
}
export default defineConfig(({ mode, command }) => {
    console.log(mode, command)
    console.log(loadEnv(mode, absPath('./env')));
    return {
        ...envMap[command](mode),
        envDir: './env',
        envPrefix: 'VITE_',
        css: {
            // 开启css的sourceMap
            devSourcemap: true,
            preprocessorOptions: {
                less: {
                    // 传递给对应的css预处理器的配置项
                    math: 'always',
                    globalVars: {
                        mianColor: 'pink'
                    }
                }
            }
        },
        resolve: {
            alias: {
                '@': path.resolve(__dirname, './src')
            }
        }
    }
})